from google.appengine.ext import db
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app

import app


class Update(webapp.RequestHandler):

  def get(self):
    out = []
    routers = app.Router.all()
    for router in routers:
      is_done = app.Metrics.MakeSnapshot(router)
      if is_done:
        out.append('Snapshot for %s successfully done<br/>' % router.address)
      else:
        out.append('Snapshot for %s FAILED<br/>' % router.address)

    self.response.out.write('\n'.join(out))


application = webapp.WSGIApplication([
    ('/update', Update)
], debug=True)


def main():
  run_wsgi_app(application)


if __name__ == "__main__":
  main()
